#ifndef PCAP_HANDLER_H
#define PCAP_HANDLER_H

#define WPCAP
#define HAVE_REMOTE
#include <pcap.h>
#include <windows.h>

#include <iostream>
#include "bitwise.h"

// A helper class to hold a packet data.
class CPacket {
public:
	struct pcap_pkthdr *header;
	const u_char *data; /* Pointer to the actual data */
	CPacket() { header=new pcap_pkthdr; }
	~CPacket() { delete header; }
};

// Base class that does the dirty work initializing Pcap.
// You must derive this class and define the virtual function
// ParsePacket() according to your needs.
class PcapHandler {
public:
	PcapHandler();
	// Initalize Pcap, devices, etc.
	int Init(int DeviceNum, std::string Filter);
	// Start the capture loop. This actually calls ParsePacket().
	int StartCaptureLoop();
	/* XXX NOTICE XXX */
	/*----------------*/
	// This you will have to define in a derived class.
	virtual int ParsePacket();
protected:
	class CPacket Packet;
	pcap_t *adhandle;
	// Prints the data in a packet for the specified length.
	void Print(const u_char *data, unsigned int length);
};

#endif

